﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Faz.SideWinderSC.Client">

    <Style x:Key="WindowButtonStyle"
           TargetType="Button"
           BasedOn="{StaticResource ImageButtonStyle}">
        <Setter Property="Margin"
                Value="1" />
    </Style>

    <ControlTemplate x:Key="WindowTemplate"
                     TargetType="Window">
        <Border x:Name="border"
                Background="White"
                BorderBrush="#f886d0"
                BorderThickness="1"
                Margin="20">
            <Border.Effect>
                <DropShadowEffect Color="#6c6c6c"
                                  BlurRadius="20"
                                  Direction="315"
                                  ShadowDepth="2" />
            </Border.Effect>
            <Grid>
                <Thumb x:Name="PART_TitleBar"
                       VerticalAlignment="Top"
                       Height="30"
                       Cursor="SizeAll">
                    <Thumb.Template>
                        <ControlTemplate TargetType="Thumb">
                            <Border Background="Transparent" Cursor="{TemplateBinding Cursor}" />
                        </ControlTemplate>
                    </Thumb.Template>
                </Thumb>

                <!--  Close and Resize buttons -->
                <Border VerticalAlignment="Top"
                        HorizontalAlignment="Right"
                        Background="Transparent"
                        Padding="7 9 7 9">
                    <StackPanel Orientation="Horizontal">
                        <Button Command="{x:Static local:Commands.WindowChangeState}"
                                CommandParameter="{x:Static WindowState.Minimized}"
                                Style="{StaticResource WindowButtonStyle}">
                            <Image Stretch="None"
                                   Source="../Images/window-minimize.png" />
                        </Button>
                        <Button x:Name="maximize"
                                Command="{x:Static local:Commands.WindowChangeState}"
                                CommandParameter="{x:Static WindowState.Maximized}"
                                Style="{StaticResource WindowButtonStyle}">
                            <Image Stretch="None"
                                   Source="../Images/window-maximize.png" />
                        </Button>
                        <Button x:Name="normal"
                                Command="{x:Static local:Commands.WindowChangeState}"
                                CommandParameter="{x:Static WindowState.Normal}"
                                Style="{StaticResource WindowButtonStyle}"
                                Visibility="Collapsed">
                            <Image Stretch="None"
                                   Source="../Images/window-normal.png" />
                        </Button>
                        <Button Command="{x:Static local:Commands.WindowClose}"
                                Style="{StaticResource WindowButtonStyle}">
                            <Image Stretch="None"
                                   Source="../Images/window-close.png" />
                        </Button>
                    </StackPanel>
                </Border>

                <!-- TODO Add resize and move controls -->
                <ContentPresenter Margin="30 30 30 30" />

                <ResizeGrip x:Name="resize"
                            Visibility="Collapsed"
                            VerticalAlignment="Bottom"
                            HorizontalAlignment="Right" />
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="WindowState"
                     Value="Maximized">
                <Setter TargetName="border"
                        Property="Margin"
                        Value="0" />
                <Setter TargetName="maximize"
                        Property="Visibility"
                        Value="Collapsed" />
                <Setter TargetName="normal"
                        Property="Visibility"
                        Value="Visible" />
                <Setter TargetName="resize"
                        Property="Visibility"
                        Value="Collapsed" />
            </Trigger>
            <Trigger Property="ResizeMode"
                     Value="CanResizeWithGrip">
                <Setter TargetName="resize"
                        Property="Visibility"
                        Value="Visible" />
            </Trigger>
            <Trigger Property="ResizeMode"
                     Value="CanMinimize">
                <Setter TargetName="maximize"
                        Property="Visibility"
                        Value="Collapsed" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="WindowStyle"
           TargetType="Window">
        <Setter Property="Template"
                Value="{StaticResource WindowTemplate}" />
        <Setter Property="ShowInTaskbar"
                Value="True" />
        <Setter Property="ResizeMode"
                Value="CanResizeWithGrip" />
        <Setter Property="WindowState"
                Value="Normal" />
        <Setter Property="WindowStyle"
                Value="None" />
        <Setter Property="AllowsTransparency"
                Value="True" />
    </Style>

</ResourceDictionary>
